import _ from 'lodash';
// import printMe from '../assets/js/print.js';

function component() {
	let element = document.createElement('div');
	let eleDate = document.createElement('h3');
	// Lodash, now imported by this script
	element.innerHTML = _.join(['Hello---', 'webpack---'], '点击按钮后才加载print.js文件（懒加载）--- ');
	const date = new Date()
	eleDate.innerHTML = date.toLocaleDateString() + date.toLocaleTimeString()
	
	// 创建按钮
	let btn = document.createElement('button');
	btn.innerHTML = 'Click me and check the console!';
   	btn.onclick = (e) => import(/* webpackChunkName : 'printMe'*/ '../assets/js/print.js').then((module) => {
		const printMe = module.default
		const date = new Date()
		eleDate.innerHTML = date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
		printMe()
		alert(eleDate.innerHTML)
	})

	element.appendChild(eleDate);
   	element.appendChild(btn);
	return element;
}

document.body.appendChild(component());